<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
	<script type="text/javascript" src="../js/tooltip.js"></script>
	
	<script type="text/javascript" src="../js/common.js"></script>

	<script type="text/javascript" src="../js/ui.core.js"></script>
	
	<script type="text/javascript" src="../js/ui.dialog.js"></script>
	
    <!-- Sheet Css -->
	
    <link rel="stylesheet" type="text/css" media="all" title="Style sheet" href="../skins/css/formstyle.css" />
	
	<!-- Javascript -->
  
    <!-- customized header contents -->
	<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<script type="text/javascript" src="../js/hopdong.js">
</script>
<script type="text/javascript" src="../js/hopdong_ct.js">
</script>
<script type="text/javascript" src="../js/core.js">
</script>

<script type="text/javascript" src="../js/hopdong_add.js">
</script>

<link rel="stylesheet" type="text/css" href="http://tamnguyen.gencrm.com/modules/hopdong/css/style.css" />
<link rel="stylesheet" href="../skins/css/jscal2.css" type="text/css" />
<link rel="stylesheet" href="../skins/css/border-radius.css" type="text/css" />
<link rel="stylesheet" href="../skins/css/steel.css" type="text/css" />



<script type="text/javascript" src="../js/xajax_core.js" charset="UTF-8"></script>
	<script type="text/javascript">
  
  	var JSTRAN = {language:{"_LANGCODE":"vi","_YES":"Yes","_NO":"No","_OK":"\u0110\u1ed3ng \u00fd","_CANCEL":"H\u1ee7y b\u1ecf","_PLEASEWAIT":"Please Wait","_FETCHING":"Loading...","_TAKINGBACK":"Taking you back to where you were....","_US_LOGGEDOUT":"B\u1ea1n \u0111\u00e3 tho\u00e1t kh\u1ecfi h\u1ec7 th\u1ed1ng","_LOGOUT":"Logout","_SUBJECT":"Subject","_ADD":"Add","_EDIT":"Edit","_DELETE":"X\u00f3a","_CLOSE":"Close","_SUBMIT":"Submit","_NOPERM":"B\u1ea1n ch\u01b0a \u0111\u01b0\u1ee3c quy\u1ec1n truy c\u1eadp v\u00e0o khu v\u1ef1c n\u00e0y.","_ERRORS":"Errors","_SEARCH":"Search","_ALL":"All","_TITLE":"Title","_OPTIONS":"Options","_LOGIN":"User Login","_USERNAME":"Username: ","_PASSWORD":"Password: ","_SELECT":"Select","_IMAGE":"Image","_SEND":"Send","_ASCENDING":"Ascending order","_DESCENDING":"Descending order","_BACK":"Back","_CONFIRM":"X\u00e1c nh\u1eadn","_GENCRM_URL":"http:\/\/tamnguyen.gencrm.com","_ERROR_OCCURED":"C\u00f3 l\u1ed7i x\u1ea3y ra","URL":"http:\/\/tamnguyen.gencrm.com","_BAN_CHUA_CHON_CLSP":"B\u1ea1n ch\u01b0a ch\u1ecdn ch\u1ee7ng lo\u1ea1i s\u1ea3n ph\u1ea9m","_VAO_LUC":"V\u00e0o l\u00fac","_BAN_CHUA_CHON_SP":"B\u1ea1n ch\u01b0a ch\u1ecdn s\u1ea3n ph\u1ea9m","_BAN_CHUA_NHAP_SO_LUONG":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 l\u01b0\u1ee3ng","_SO_LUONG_PHAI_LON_HON_KHONG":"S\u1ed1 l\u01b0\u1ee3ng mua ph\u1ea3i l\u1edbn h\u01a1n 0","ALERT_KH_HD":"B\u1ea1n ch\u01b0a ch\u1ecdn kh\u00e1ch h\u00e0ng","_BAN_CHUA_NHAP_SO_TIEN_THU":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 ti\u1ec1n thu","_BAN_PHAI_NHAP_SO_TIEN_THU_DUONG":"S\u1ed1 ti\u1ec1n thu ph\u1ea3i > 0","_BAN_CHUA_NHAP_SO_TIEN_CHI":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 ti\u1ec1n chi","_BAN_PHAI_NHAP_SO_TIEN_CHI_DUONG":"B\u1ea1n ph\u1ea3i nh\u1eadp s\u1ed1 ti\u1ec1n chi > 0","_GIA_BAN_PHAI_DUONG":"Gi\u00e1 b\u00e1n ph\u1ea3i >= 0","_VAT_PHAI_LON_HON_HOAC_BANG_KHONG":"Vat nh\u1eadp ph\u1ea3i d\u01b0\u01a1ng!","decimal":",","lamtron":"0","separator":".","DINH_DANG":"1","ngayht":"16\/01\/2013","donhang":0,"view":0,"_MA_HD_CHUA_NHAP":"B\u1ea1n ch\u01b0a nh\u1eadp m\u00e3 h\u1ee3p \u0111\u1ed3ng","_TEN_HOP_DONG_CHUA_NHAP":"B\u1ea1n ch\u01b0a nh\u1eadp t\u00ean h\u1ee3p \u0111\u1ed3ng","_GIA_TRI_HOP_DONG_KHONG_DUOC_RONG":"B\u1ea1n ch\u01b0a th\u00eam chi ti\u1ebft h\u1ee3p \u0111\u1ed3ng","ALERT_KT_HON_BD":"Ng\u00e0y k\u1ebft th\u00fac ph\u1ea3i >= ng\u00e0y b\u1eaft \u0111\u1ea7u","ALERT_DV_TH":"B\u1ea1n ch\u01b0a ch\u1ecdn \u0111\u01a1n v\u1ecb qu\u1ea3n l\u00fd","ALERT_NGUOI_TH":"B\u1ea1n ch\u01b0a ch\u1ecdn ng\u01b0\u1eddi qu\u1ea3n l\u00fd","_SO_TIEN_CHI_PHAI_DUONG":"S\u1ed1 ti\u1ec1n chi ph\u1ea3i l\u1edbn h\u01a1n 0","_MA_HOP_DONG_DA_TON_TAI":"M\u00e3 h\u1ee3p \u0111\u1ed3ng \u0111\u00e3 t\u1ed3n t\u1ea1i","_ALERT_NGAY_CHI_TT_LONHON_NGAY_CHI":"Ng\u00e0y chi th\u1ef1c t\u1ebf ph\u1ea3i >= ng\u00e0y chi","_BAN_CHUA_CHON_NGAY_CHI_THUC_TE":"B\u1ea1n ch\u01b0a ch\u1ecdn ng\u00e0y chi th\u1ef1c t\u1ebf","Hdo_Id":0,"_BAN_CHUA_NHAP_SO_TIEN_TT":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 ti\u1ec1n thanh to\u00e1n","_SO_TIEN_TT_PHAI_DUONG":"S\u1ed1 ti\u1ec1n thanh to\u00e1n ph\u1ea3i l\u1edbn h\u01a1n 0","_ALERT_NGAY_TT_TT_LONHON_NGAY_CHI":"Ng\u00e0y thanh to\u00e1n th\u1ef1c t\u1ebf ph\u1ea3i >= ng\u00e0y thanh to\u00e1n","_BAN_CHUA_CHON_NGAY_TT_THUC_TE":"B\u1ea1n ch\u01b0a ch\u1ecdn ng\u00e0y thanh to\u00e1n th\u1ef1c t\u1ebf","_BAN_CHUA_NHAP_SO_LAN_NHAC":"B\u1ea1n ch\u01b0a nh\u1eadp s\u1ed1 l\u1ea7n nh\u1eafc","_SO_LAN_NHAC_PHAI_DUONG":"S\u1ed1 l\u1ea7n nh\u1eafc ph\u1ea3i d\u01b0\u01a1ng","_BAN_CHUA_NHAP_NOI_DUNG_NHAC":"B\u1ea1n ch\u01b0a nh\u1eadp n\u1ed9i dung nh\u1eafc","_THANG":"th\u00e1ng","_NAM":"n\u0103m","_ALERT_NGAY_TT_TT_NHOHON_NGAY_HT":"Ng\u00e0y thanh to\u00e1n th\u1ef1c t\u1ebf ph\u1ea3i nh\u1ecf h\u01a1n ho\u1eb7c b\u1eb1ng ng\u00e0y hi\u1ec7n t\u1ea1i!"}}
  	</script>  
    <script src="../js/NumberFormat154.js"></script>
<script type="text/javascript">
function formatNumber(obj){
				var numberFormat = new NumberFormat(obj.value);
				numberFormat.setSeparators(true, '.', ',');
				numberFormat.setPlaces(0);
				obj.value = numberFormat.toFormatted();
				var obj1 = obj.name + '_';
				document.getElementById(obj1).value = numberFormat.toUnformatted();
			}
</script>	

<script type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce.js"></script>

					 <script type="text/javascript">						
						tinyMCE.init({
							entity_encoding : "raw",
							mode : "exact",
							elements : "txtnoidung",
							theme : "advanced",
							width : "850",
							height : "150", 
							plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,",

						
							theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect,undo,redo,|,link,unlink,image,forecolor,backcolor,pasteword",
							theme_advanced_buttons2 : "",
							theme_advanced_buttons3 : "",
							theme_advanced_buttons4 : "",
							theme_advanced_toolbar_location : "top",
							theme_advanced_toolbar_align : "left",							
							theme_advanced_resizing : false,

							
							content_css : "css/content.css",

							
							template_external_list_url : "lists/template_list.js",
							external_link_list_url : "lists/link_list.js",
							external_image_list_url : "lists/image_list.js",
							media_external_list_url : "lists/media_list.js",

							
							style_formats : [
								{title : 'Bold text', inline : 'b'},
								{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
								{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
								{title : 'Example 1', inline : 'span', classes : 'example1'},
								{title : 'Example 2', inline : 'span', classes : 'example2'},
								{title : 'Table styles'},
								{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
							],

							
							template_replace_values : {
								username : "Some User",
								staffid : "991234"
							}
						});
</script>

<script language="javascript">
function validate_form(thisform)
{
with (thisform)
{
		if (validate_required(txtcode,"Bạn chưa nhập mã đơn hàng !")==false)
			{txtcode.focus();return false;}
		if (validate_required(txtHoten,"Bạn chưa nhập tên đơn hàng !")==false)
			{txtHoten.focus();return false;}
	 
		if (validate_required(khachhang,"Bạn chưa chọn khách hàng!")==false)
			{khachhang.focus();return false;}
		
		
		if (validate_required(donviquanly,"Bạn chưa chọn đơn vị quản lý!")==false)
			{donviquanly.focus();return false;}	
		if (validate_required(txtNguoiquanly,"Bạn chưa chọn người quản lý!")==false)
			{txtNguoiquanly.focus();return false;}	
}
}
</script>
<script src="http://tamnguyen.gencrm.com/include/calendar/vn-cal.js" type="text/javascript">
</script>
<script src="http://tamnguyen.gencrm.com/include/calendar/gencal.js" type="text/javascript">
</script>
<script src="http://tamnguyen.gencrm.com/include/calendar/lang/vi.js" type="text/javascript">
</script>




<!-- overlay -->
<div id="global">
	<div id="overlay" onclick="parent_disable();">		
	</div>
</div>
<!-- end overlay -->
<?php 
	$id=$_GET['id'];
	$sql_sua=mysql_query("select * from donhang where id='$id'");
	$row_sua=mysql_fetch_array($sql_sua);
?>
<form style="padding:0; margin:0" action="index.php?tn=contract&hd=order_xl" method="post" onsubmit="return validate_form(this);" name="frmAddMessage" enctype="multipart/form-data" id="theform">
         <input type="hidden" name="id_dh" value="<?php echo $row_sua['id'];?>" />
        <div class="clear" style="height:5px"></div>
        <div class="bodycontent"> 
        <table class="box-vang" border="0" cellpadding="0" cellspacing="0" width="100%">
          <tbody><tr>
            <td class="t-l" width="8px"></td>
            <td class="t-c"></td>
            <td class="t-r" width="8px"></td>
          </tr>
          <tr class="light">
            <td class="c-l"></td>
            <td class="c-c"><table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tbody><tr class="light">
                  <td class="title-red" colspan="2" align="left" id="canhan_tiemnang">&nbsp;Sửa đơn hàng</td>
                  
                </tr>
               			   
                <tr><td class="title-red1" colspan="2">Thông tin chung</td></tr>
				
				 <tr>
                 <td colspan="2">
                   
				   <div id="customer_info" style="display: block;">
                       <table width="100%">
					    <tr class="light">
                  <td width="50%">
         			<table width="100%" >
                    <tr><td width="117" align="right">Mã đơn hàng: </td>
                        <td width="300">
                        <input type="text" name="txtcode" style="width:300px;" value="<?php echo $row_sua['code'];?>"/> <span style="color:#F00"> *</span>
                        </td>
                    </tr>
                   <tr><td width="117" align="right">Tên đơn hàng: </td>
                        <td width="300">
                        <input type="text" name="txtHoten" style="width:300px;" value="<?php echo $row_sua['name'];?>"/> <span style="color:#F00"> *</span>
                        </td>
                    </tr>
             
                    </table> 
                  </td> 
                 <td width="50%">
         			<table width="100%">                   

                       <tr>
                       		<td align="right">Ngày bán:</td>
                            <td>
                            	<input type="text"  id="ngayban" name="ngayban" style="width:300px;" value="<?php echo $row_sua['ngayban'];?>">
                           
                            </td>
                      </tr>
                      <tr>
                       	<td align="right">Khách hàng</td>
                      	<td>
                        <?php 
							$sql_kh=mysql_query("select id,name_kh,name_com from customers where id='".$row_sua['kh_id']."'");
							$row_kh=mysql_fetch_array($sql_kh);
						?>
                        	<input type="hidden" name="Kha_Id" id="Kha_Id">
                            <input type="hidden" name="kh_id" value="<?php echo $row_sua['kh_id'];?>" />
                        	<input type="text" name="khachhang" style="width:300px;" id="khachhang" readonly="readonly" value="<?php echo $row_kh['name_kh'];echo $row_kh['name_com']?>"/>
                            <span style="color:#F00"> *</span>
                            <img src="../skins/images/btn_Lookup.png" onclick="popup('modules/customers/popupKH.php',800,500);" align="absmiddle">
                    <img width="16px" height="16px" align="absmiddle" onclick="document.getElementById(&#39;Kha_Id&#39;).value=&#39;&#39;;document.getElementById(&#39;khachhang&#39;).value=&#39;&#39;;" alt="del" src="../skins/images/Clear.gif">
                        </td>
                  	</tr>
                    </table> 
                  </td> 
                </tr> 

				     </table>
                </div>
                
               <script>
	var cal = Calendar.setup({
	  onSelect: function(cal) { cal.hide() },
	  weekNumbers: true
  });
	cal.manageFields("ngayban", "ngayban", "%d/%m/%Y");
	
	</script>
			   </td></tr>
               
                <tr><td class="title-red1" colspan="2">Chi tiết đơn hàng</td></tr>
                 <tr>
                 	<td colspan="4">             
        				<table width="100%" cellspacing="0" cellpadding="0">
							<tr>
								<td>
                                 <div style="margin-left:10px;margin-right:10px;width:98%;overflow: hidden;" >
                             <?php $sql_dem=mysql_query("select count(*) as so_ban_ghi from donhang_ct where donhang_id='$id'");
							 	$row_dem=mysql_fetch_array($sql_dem);
							 ?>
                            <input type="hidden" id="count_hdct" name="count_hdct" value="<?php echo $row_dem['so_ban_ghi'];?>" />
                            <input type="hidden" id="count_del_hdct" name="count_del_hdct" value="<?php echo $row_dem['so_ban_ghi'];?>" />
                            <input type="hidden" id="table" name="table" value="don_hang" />
                            <input type="hidden" id="id_table" name="id_table" value="<?php echo $row_sua['id'];?>" />
                                    <div class="tableHead" style="overflow: hidden;">
                                        <div style="margin-right: 17px;">
                                            <div class="firstCol" style="color:#0070BA;width:2.7%;" ><b>STT</b></div>
                                            <div class="Cols" style="color:#0070BA;width:12%;"><b>Loại sản phẩm</b></div>
                                            <div class="Cols" style="color:#0070BA;width:12%;"><b>Sản phẩm</b></div>
                                            <div class="Cols" style="color:#0070BA;width:8%;"><b>ĐVT</b></div>
                                            <div class="Cols" style="color:#0070BA;width:10%;"><b>Đơn giá</b></div>
                                            <div class="Cols" style="color:#0070BA;width:7%;"><b>Số lượng</b></div>
                                            <div class="Cols" style="color:#0070BA;width:10%;"><b>Cộng</b></div>
                                            <div class="Cols" style="color:#0070BA;width:10%;"><b>VAT</b></div>
                                            <div class="Cols" style="color:#0070BA;width:11%;"><b>Thành tiền</b></div>
                                            <div class="Cols" style="color:#0070BA;float:right;padding-right:10px;"><b>Thao tác</b></div>
                                        </div>
                                    </div>
							<div  style="max-height:300px; width:100%;overflow-y:scroll;z-index: -1;clear: both;">
								<div id="divSelectedNames">
                                <?php $sql_hdct=mysql_query("select * from donhang_ct where donhang_id='$id' order by id asc");
									 
									while($row_hdct=mysql_fetch_array($sql_hdct))
									{
								?>
									<div id="row_sua_<?php echo $row_hdct['id_row'];?>">
                                    
                                        <div id="row_<?php echo $row_hdct['id_row'];?>" style="overflow: hidden;display:block" class="row01">
                                            <div style="width:2.7%;text-align:center;" class="firstCol">
                                               <?php echo $row_hdct['id_row'];?>
                                            </div>
                                            <div style="width:12%;" class="Cols">
                                                <?php  
												$lsp=$row_hdct['lsp'];
												$lsp_name=catchinfor($lsp,"services_type_id","services_type_name","tb_services_type");	
												echo $lsp_name;
												?>
                                            </div>
                                            <div style="width:12%;" class="Cols">
                                                <?php  
												$sp=$row_hdct['sp'];
												$sp_name=catchinfor($sp,"IDproduct","Namepro","tb_product");	
												echo $sp_name;
												?>
                                            </div>
                                            <div style="width:8%;" class="Cols">
                                                <?php  
												$dv=$row_hdct['dv'];
												$dv_name=catchinfor($dv,"services_type_id","services_type_name","tb_services_type");	
												echo $dv_name;
												?>
                                            </div>
                                            <div style="width:10%;text-align:right;" class="Cols">
                                                <?php echo $row_hdct['dongia']?>	
                                            </div>
                                            <div style="width:7%;text-align:center;" class="Cols">
                                                <?php echo $row_hdct['soluong']?>		
                                            </div>
                                            <div style="width:10%;text-align:right;" class="Cols">
                                                <?php echo $row_hdct['cong']?>	
                                            </div>
                                            <div style="width:10%;" class="Cols">
                                                <?php echo $row_hdct['vat']?>	
                                            </div>
                                            <div style="width:11%;text-align:right;" class="Cols">
                                                <?php echo $row_hdct['thanhtien']?>	
                                            </div>
                                            <div style="float:right;padding-right: 10px;" class="Cols">
                                                <b><span onclick="change_display('sua_hdct_<?php echo $row_hdct['id_row'];?>');change_display('row_<?php echo $row_hdct['id_row'];?>');document.getElementById('lsp_id_<?php echo $row_hdct['id_row'];?>').focus();" style="color:#FF9028;cursor: pointer;">Sửa</span>&nbsp;<span onclick="delete_hdct(<?php echo $row_hdct['id_row'];?>,'<?php echo $row_hdct['id'];?>','<?php echo $row_hdct['thanhtien']?>','<?php echo $row_hdct['cong']?>','<?php echo $row_hdct['tienvat']?>');" style="color:#FF0000;cursor: pointer;">Xóa</span></b>
                                            </div>
                                          
                                        </div>
                                      
                                        <div style="overflow: hidden;height:30px;display:none;" id="sua_hdct_<?php echo $row_hdct['id_row'];?>" class="row01">
                                            <div style="width:2.7%;text-align:center;" class="firstCol"><?php echo $row_hdct['id_row'];?></div>
                                            <div style="width:12%;" class="Cols">
                                                <select id="lsp_id_<?php echo $row_hdct['id_row'];?>" name="Cls_Id_<?php echo $row_hdct['id_row'];?>" onchange="show_spham(this.value);" style="width:100%;">
                                                    <option value="">Lựa chọn</option>
                                                    <?php 
                                                        $sql_Lsp=mysql_query("select services_type_id,services_type_name,phanloai_id from 
																		tb_services_type where phanloai_id=18");
                                                        while($rs_Lsp=mysql_fetch_array($sql_Lsp))
                                                        {
                                                    ?>
                                                                <option value="<?php echo $rs_Lsp['services_type_id'];?>" <?php if($rs_Lsp['services_type_id']==$lsp){?> selected="selected"<?php }?>>
																<?php echo $rs_Lsp['services_type_name'];?>
                                                                </option>
                                                    <?php }?>		
                                                </select>
                                            </div>
                                            <div id="arr_sp_<?php echo $row_hdct['id_row'];?>" style="width:12%;" class="Cols">
                                                <select onchange="check_gia_vat(this.value,document.getElementById('soluong_1').value,1);" style="width:100%;" id="Sph_Id_<?php echo $row_hdct['id_row'];?>" name="Sph_Id_<?php echo $row_hdct['id_row'];?>">
                                                    <option value="">Lựa chọn</option>
                                                  <?php $sql_sp=mysql_query("select IDproduct,Namepro,services_type_id from tb_product where services_type_id='$lsp'");
												  	while($rs_sp=mysql_fetch_array($sql_sp))
													{
												  ?>  
                                                    <option  value="<?php echo $rs_sp['IDproduct'];?>"<?php if($rs_sp['IDproduct']==$sp){?> selected="selected"<?php }?>><?php echo $rs_sp['Namepro'];?></option>
                                                    <?php }?>
                                                 </select>
                                            </div>
                                            <div style="width:8%;" class="Cols">
                                                <select id="dvt_id_<?php echo $row_hdct['id_row'];?>" name="Dvt_Id_<?php echo $row_hdct['id_row'];?>" style="width:100%;">
                                                    <option value="">Lựa chọn</option>
                                                    <?php $sql_dv=mysql_query("select services_type_id,services_type_name,phanloai_id from  tb_services_type where phanloai_id=23");
                                                        while($rs_dv=mysql_fetch_array($sql_dv))
                                                        {
                                                    ?>
                                                                <option value="<?php echo $rs_dv['services_type_id'];?>" <?php if($rs_dv['services_type_id']==$dv){?> selected="selected"<?php }?>><?php echo $rs_dv['services_type_name'];?></option>
                                                    <?php }?>
                                                </select>
                                            </div>
                                            <div style="width:10%;" class="Cols">
                                                <input type="text" onblur="formatNumber(this.form.giaban_<?php echo $row_hdct['id_row'];?>);tien_hdct(<?php echo $row_hdct['id_row'];?>);" id="giaban_<?php echo $row_hdct['id_row'];?>" onclick="toUnformattedNumber(\'giaban_<?php echo $row_hdct['id_row'];?>\');"  name="giaban_<?php echo $row_hdct['id_row'];?>" value="<?php echo $row_hdct['dongia'];?>" onkeypress="return isNumberKey(event);" style="width:95%;">
                                                <input type="hidden" id="giaban_<?php echo $row_hdct['id_row'];?>_" value="<?php echo $row_hdct['dongia'];?>" name="giaban_<?php echo $row_hdct['id_row'];?>_">
                                                <input type="hidden" id="gia_codinh_<?php echo $row_hdct['id_row'];?>" value="1" name="gia_codinh_<?php echo $row_hdct['id_row'];?>">
                                            </div>
                                            <div style="width:7%;" class="Cols">
                                                <input type="text" onkeyup="tien_hdct(<?php echo $row_hdct['id_row'];?>);" size="30" value="<?php echo $row_hdct['soluong'];?>" id="soluong_<?php echo $row_hdct['id_row'];?>" name="soluong_<?php echo $row_hdct['id_row'];?>" style="width:95%;" onkeypress="return isNumberKey(event);">
                                            </div>
                                            <div style="width:10%;" class="Cols">
                                                <input type="text" value="<?php echo $row_hdct['cong'];?>" id="tong_cdd_<?php echo $row_hdct['id_row'];?>" style="width:95%;" readonly="readonly">
                                                <input type="hidden" value="<?php echo $row_hdct['cong'];?>" name="tong_tien_hdct_<?php echo $row_hdct['id_row'];?>" id="tien_tong_<?php echo $row_hdct['id_row'];?>">
                                            </div>
                                            <div style="width:10%;" class="Cols">
                                                <input type="hidden" value="<?php echo $row_hdct['vat']; ?>" id="vat_dd_<?php echo $row_hdct['id_row'];?>" style="width:95%;">
                                                <input type="hidden" value="<?php echo $row_hdct['tienvat']; ?>" id="tien_vat_<?php echo $row_hdct['id_row'];?>" name="tien_vat_1">
                                                <input type="text" value="<?php echo $row_hdct['vat'];?>" id="vat_<?php echo $row_hdct['id_row'];?>" name="vat_<?php echo $row_hdct['id_row'];?>" onkeyup="tien_hdct(<?php echo $row_hdct['id_row'];?>);" onkeypress="return isNumberKey(event);" style="width:95%;">
                                            </div>
                                            <div style="width:11%;" class="Cols">
                                                <input type="text" value="<?php echo $row_hdct['thanhtien'];?>" id="thanhtien_dd_<?php echo $row_hdct['id_row'];?>" style="width:95%;" readonly="readonly">
                                                <input type="hidden" value="<?php echo $row_hdct['thanhtien'];?>" id="thanhthien_<?php echo $row_hdct['id_row'];?>" name="thanhthien_1">
                                            </div>
                                            <div style="float:right;padding-right: 10px;" class="Cols">
                                                <span style="color:#FF9028;cursor: pointer;" onclick="check_add_hdct(<?php echo $row_hdct['id_row'];?>,1,'<?php echo $row_hdct['thanhtien'];?>','<?php echo $row_hdct['id'];?>','<?php echo $row_hdct['cong'];?>','<?php echo $row_hdct['tienvat']; ?>');"><b>Lưu</b></span>&nbsp;<span onclick="change_display('sua_hdct_<?php echo $row_hdct['id_row'];?>');change_display('row_<?php echo $row_hdct['id_row'];?>');" style="color:#FF0000;cursor: pointer;"><b>Hủy</b></span>
                                            </div>
                                        </div>

						</div>
                         <?php }?> 
                      </div>
								<div class="row01" id="them_hdct" style="overflow: hidden;height:30px;display:none;">
									<div class="firstCol" id="display_count_hdct" style="width:2.7%;text-align:center;"></div>
									<div class="Cols" style="width:12%;">
		<select id="lsp_id_0" name="Cls_Id_0" onChange="show_spham(this.value);" style="width:100%;">
			<option value="">Lựa chọn</option>
            <?php 
				$sql_Lsp=mysql_query("select services_type_id,services_type_name,phanloai_id from tb_services_type where phanloai_id=18");
				while($rs_Lsp=mysql_fetch_array($sql_Lsp))
				{
			?>
						<option value="<?php echo $rs_Lsp['services_type_id'];?>"><?php echo $rs_Lsp['services_type_name'];?></option>
			<?php }?>		
		</select>
									</div>
									<div class="Cols" style="width:15%;"  id="arr_sp_0">
		<select onChange="check_gia_vat(this.value);" name="Sph_Id_0" id="Sph_Id_0" style="width:100%;">
	<option value="">Lựa chọn</option>
	
	</select>
									</div>
									<div class="Cols" style="width:8%;">
		<select id="dvt_id_0" name="Dvt_Id_0" style="width:100%;">
			<option value="">Lựa chọn</option>
            <?php $sql_dv=mysql_query("select services_type_id,services_type_name,phanloai_id from  tb_services_type where phanloai_id=23");
				while($rs_dv=mysql_fetch_array($sql_dv))
				{
			?>
						<option value="<?php echo $rs_dv['services_type_id'];?>" ><?php echo $rs_dv['services_type_name'];?></option>
			<?php }?>
					</select>
									</div>
									<div class="Cols" style="width:10%;" id="price">
		<input type="text" style="width:95%;" onKeyPress="return isNumberKey(event);"  onclick="toUnformattedNumber('giaban_0');" value="" name="giaban_0"  id="giaban_0"  onblur="formatNumber(this.form.giaban_0);tien_hdct(0);" />
		<input type="hidden" name="giaban_0_" value="" id="giaban_0_" />
		<input type="hidden" name="gia_codinh_0" value="0" id="gia_codinh_0" />
									</div>
                                    <div class="Cols" style="width:7%;">
                                        <input onKeyPress="return isNumberKey(event);"  style="width:95%;" type="text" name="soluong_0" id="soluong_0" value="" size="30" onBlur="tien_hdct(0);" />
                                    </div>
                                    <div class="Cols" style="width:10%;">
                                        <input type="text" disabled="true" style="width:95%;" id="tong_cdd_0" />
                                        <input type="hidden" id="tien_tong_0" name="tong_tien_hdct_0" value="0" />
                                    </div>
                                    <div class="Cols" style="width:10%;">
                                        <input type="hidden" disabled="true" style="width:95%;" id="vat_dd_0" />
                                        <input type="hidden" name="tien_vat_0" id="tien_vat_0" value="" />
                                        <input type="text" style="width:95%;" name="vat_0" id="vat_0" onBlur="tien_hdct(0);" value="" onKeyPress="return isNumberKey(event);"  />
                                    </div>
                                    <div class="Cols" style="width:11%;">
                                        <input type="text" disabled="true" style="width:95%;" id="thanhtien_dd_0" />
                                        <input type="hidden" name="thanhthien_0" id="thanhthien_0" value="0" />
                                    </div>
                                    <div class="Cols" style="color:#0070BA;float:right;padding-right: 10px;">
                                        <b><span onClick="check_add_hdct(0,0,0,'',0,0);" style="color:#FF9028;cursor: pointer;">Lưu</span>&nbsp;<span style="color:#FF0000;cursor: pointer;" onClick="huy_them_hdct();">Hủy</span></b>
                                    </div>
							</div>
		</div>
        		<div>
                	
                    <input type="hidden"  name="giatri" id="giatri" value=""/>
					<input type="hidden" name="Gia_Tri" id="giatri_" value=""/>	
                    <input type="hidden"  id="tongchiphi" name="tongchiphi"  value="" />
					<input type="hidden"  name="Tong_Chi_Phi" id="tongchiphi_" value=""/>
                    <input type="hidden"  id="tiendatt" name="tiendatt" size="30" value="" />
					<input type="hidden"  name="Tien_Da_TT" id="tiendatt_" value=""/>
                    <input type="hidden"  id="tienphaitt" name="tienphaitt" size="30" value=""/>
					<input type="hidden"  name="Tien_Phai_TT" id="tienphaitt_" value=""/>
                </div>
               <div style="float:right; margin-top:10px;width:44%;margin-right:17px;" >
                    <b>
                    <div class="firstCol" style="width:24%;border:none;text-align:right;"  id="tong_tien_dd" ></div>
                    <div class="Cols" style="width:24%;border:none;text-align:right;" id="tien_vat_dd"></div>
                    <div class="Cols" style="width:24%;border:none;text-align:right;" id="giatri" ></div>
                    </b>
                    <div class="Cols" style="width:17%;border:none;" >
                       <span id="bt_add_hdct"><input type="button" value="Thêm mới" class="blue_add" style="width:auto;" onclick="change_display('them_hdct');counthdct();"/></span>
                    </div>
</div>

                            	</td>
                        	</tr>
                    	</table>
                 	</td>
                </tr>
                
    <script type="text/javascript">

function LoadNguoiQL(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp == null)
{
alert ("Browser does not support HTTP Request");
return;
}

var url = "modules/customers/load_room.php";
url = url + "?room_id=" + str;

xmlhttp.onreadystatechange = stateChanged;
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState == 4)
{
document.getElementById("nquanly").innerHTML = xmlhttp.responseText;

}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}

</script>     

                 <tr><td class="title-red1" colspan="2">Thông tin quản lý</td></tr>
                <tr class="light">
                <td width="50%">
         			<table width="100%">
                    
                    <tr><td width="27%" align="right">Đơn vị quản lý: </td><td width="73%">
                                      
                <select class="box_input cbo" name="donviquanly"  style="width:300px" onchange="LoadNguoiQL(this.value)">
                        	<option value="">--Lựa chọn-- </option>
                            <?php 
							$sqlcode=mysql_query("select * from tb_room");
							while($rscode=mysql_fetch_array($sqlcode))
							{
								
						?>
								<option value="<?php echo $rscode['room_id'];?>" <?php if($row_sua['manager_unit']==$rscode['room_id']){ ?> selected="selected"<?php }?>><?php echo $rscode['room_name'];?></option>
								  <?php }?>
                        </select>
                      <span style="color:#F00"> *</span>  
                    
                    </td></tr>
                    <tr><td align="right">Người quản lý: </td><td>
                    <div id="nquanly">
                    			<select  id="nv_giao" style="width:300px" name="nql">
                                	<option value="">--Lựa chọn--</option>
                                <?php $sql_ql=mysql_query("SELECT account_id,account_name,room_id FROM tb_account_admin WHERE room_id='".$row_sua['manager_unit']."'");?>
                               <?php while($rs_ql=mysql_fetch_array($sql_ql)){?>
                                 <option  value="<?php echo $rs_ql['account_id'];?>"<?php if($row_sua['manager']==$rs_ql['account_id']){ ?> selected="selected"<?php }?>><?php echo $rs_ql['account_name'];?></option>
                                <?php }?>
								</select><span style="color:#F00"> *</span>
                        </div>
                        </td></tr>
                        <tr><td align="right">Người quản lý khác: </td><td>
                        <input type="hidden" name="Nguoi_Quan_Ly_Khac" id="dsid_nql">
                        <input type="hidden" name="nguoiqlk" value="<?php echo $row_sua['manager_other'];?>">
                        <textarea cols="50" rows="1" readonly="readonly" style="width:300px;" name="nguoitheodoi" id="ds_nql" ><?php 
					  	$accont_id=explode(',',$row_sua['manager_other']);
						$so_account=count($accont_id)-1;
						for($p=1;$p<=$so_account;$p++)
						{
							$tong_account=$accont_id[$p-1];
						
							$sql_account=mysql_query("select account_id,account_name from tb_account_admin where account_id='$tong_account'");
							while($rs_account=mysql_fetch_array($sql_account))
							{
								echo $rs_account['account_name'].',';
							}
						}
					  ?></textarea>&nbsp;					
                        <span style="padding-left:5px;" class="openp_dialog2">
                        <img width="16px" height="16px" align="absmiddle" alt="pop" src="../skins/images/btn_Lookup.png">
                        </span>
                         <img width="16px" height="16px" align="absmiddle" onclick="document.getElementById(&#39;dsid_nql&#39;).value=&#39;&#39;;document.getElementById(&#39;ds_nql&#39;).value=&#39;&#39;;" alt="del" src="../skins/images/Clear.gif">
					</td></tr>            
                    </table> 
                  </td> 
              <td width="50%">
                    <table width="100%">       
                    <?php 
						$nt_id=$row_sua['creater'];
						$nguoitao=catchinfor($nt_id,"account_id","account_name","tb_account_admin");
						
						?>             
                    <tr><td width="24%" align="right">Người tạo: </td><td width="76%">
                    	<input type="text" value="<?php echo $nguoitao;?>" name="txtNguoitao" disabled="disabled" style="width:300px">
                     </td>
                    </tr>
                    <tr><td align="right">Ngày tạo: </td><td><input type="text" value="<?php echo date('d/m/Y H:i a',$row_sua['creat_time']);?>" name="txtNgaytao" disabled="disabled" style="width:300px">
                    </td>
                    </tr>    
                    <tr><td width="24%" align="right">Người cập nhật: </td><td width="76%">
                    	<input type="text" value="<?php echo $_SESSION['name'];?>" name="txtNguoisua" disabled="disabled" style="width:300px">
                     </td>
                    </tr>             
                    <tr><td align="right">Ngày cập nhật: </td><td><input type="text" value="<?php echo date('d/m/Y h:i:s a');?>" disabled="disabled" name="txtNgaycapnhat" style="width:300px">
                    </td>
                    </tr>                   
                    </table> 
                  </td> 
                </tr> 
                
           <tr>
             <td class="title-red1" colspan="2">Ghi chú</td></tr>
               <tr  onmouseover="mouse_den(this)" onmouseout="mouse_di(this)" bgcolor="">
                 <td style="padding-left:155px; padding-top:10px" colspan="2">                                   
					<textarea name="txtnoidung" id="txtnoidung" rows="15" cols="80" style="width:300px;">
                    </textarea>  
                 </td>
                     
                </tr>
               
                <tr><td height="10px"></td></tr>
                <tr><td colspan="2" style="padding-left:150px;"><input class="buttonnew" name="submit" id="submit" value="Lưu lại" type="submit">&nbsp;<input class="buttonnew" name="submit" id="submit" value="Hủy bỏ" type="submit"></td></tr>
                
              </tbody> </table></td>
            <td class="c-r"></td>
          </tr>
          <tr>
            <td class="b-l"></td>
            <td class="b-c"></td>
            <td class="b-r"></td>
          </tr>
        </tbody></table>
        
</form>
	  
	  
	  
<script>
	function call_list_user(url){
		var str = "";
		var str_id="";
		$("#nguoi_qlkhac input[type='checkbox']").each(function(){
			if($(this).is(':checked'))
			{
				if($(this).attr('name')!='DonVi'){
					str+= $(this).next().text() +', ';
					str_id+= $(this).val() +',';
				}
					
			}	
		});
				
		document.getElementById('ds_nql').value=str;	
		document.getElementById('dsid_nql').value=str_id;
	
	}
	
	

</script>

<div id="dialog2" class="khung_poup"  title="Chọn đơn vị hoặc người dùng" style="display:none;">
<div class="titi_popup"	id="titi_popup_nql" >
	<div class="title"> Chọn đơn vị hoặc người dùng </div>
	<div class="close_popup"><a href="#" onclick="close_popup_nqlk(); return false;"> <img title=" _CLOSES" src="http://tamnguyen.gencrm.com/modules/productmanager/images/close_popup.png" /></a> </div>
</div>
<div class="than_popup" style="height: 440px;">
<form id="frmNql" name="frmNql">
	<div id="nguoi_qlkhac" style="height:auto;">
		<div style="width:100%; height:auto;margin-left:20px;">
          <?php 
		
			$sql=mysql_query("select * from tb_room");
			$i=0;
		?>
        <?php while($row=mysql_fetch_array($sql))
			{$i=$i+1;
			
				$room_id=$row['room_id'];
			?>
			<div style="float:left; width:50%;">
                <div style="color: #0070BA;width:100%;float:left;text-align:left;">
                    <input type="checkbox" onclick="selectReverse('frmNql','nql_<?php echo $i;?>')" style="width:auto;" name="DonVi" class="item"><b>
					<?php echo $row['room_name']?></b>
                </div>
				<div style="color: #0070BA;width:100%;float:left;margin-left:35px;">
				 <?php 
				$sql2=mysql_query("select account_id,room_id,account_name from tb_account_admin where room_id='$room_id'");
				?>
                <?php while($rs=mysql_fetch_array($sql2)){?>			  
                     <span class="nql_<?php echo $i;?>" style="float:left;text-align:left;width:100%;">
                        <input id="nql_<?php echo $i;?>_0" type="checkbox" style="width:auto;" name="arr_Cus_Id[]" value="<?php echo $rs['account_id'];?>" class="item">&nbsp;<b><?php echo $rs['account_name'];?></b>
                     </span>
                  <?php }?> 
                     
				</div>
              
		   </div>
		    <?php }?>
	</div>
    
	</form>
	</div>	</div>
	<div class="day_popup">
		<div class="dieukhien_popup">
			<input type="hidden" name="sort_type" id="sort_type" value="">
			<input type="button" onclick="call_list_user('http://tamnguyen.gencrm.com/');close_popup_nqlk();" name="save_sp" value="Chọn" class="save">
			<input type="button" value="Hủy bỏ" class="save" onclick="close_popup_nqlk();">
		</div>
	</div>

<!--end popup-->   
